package br.fic.poo.agenda.control;

import java.awt.Font;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.WindowConstants;

import com.jgoodies.forms.factories.FormFactory;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.RowSpec;
import javax.swing.JButton;

public class SobreControl extends JInternalFrame
{

   private static final long serialVersionUID = 7785057310254729338L;

   private static SobreControl instancia;

   public static SobreControl getInstancia()
   {
      if (instancia == null)
      {
         instancia = new SobreControl();
      }
      return instancia;
   }

   private SobreControl()
   {
      setSize(600, 450);
      setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
      setResizable(false);
      setTitle("Sistema - Sobre");
      getContentPane().setLayout(
            new FormLayout(new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
               FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(347dlu;default):grow"), FormFactory.RELATED_GAP_COLSPEC,
               ColumnSpec.decode("max(27dlu;default)"), },
                  new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("max(178dlu;default):grow"),
                     FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("max(33dlu;default)"), FormFactory.RELATED_GAP_ROWSPEC,
                     FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));

      JPanel painelTopo = new JPanel();
      getContentPane().add(painelTopo, "4, 2, left, top");
      painelTopo.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(75dlu;default):grow"), }, new RowSpec[] {
               FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));

      JLabel labelContatos = new JLabel(
            "<html><p style=\"font-family: Tahoma, Helvetica, Arial, Sans-Serif;\">Agenda de Contatos e Compromissos</p><hr /><html>");
      painelTopo.add(labelContatos, "2, 2");
      labelContatos.setForeground(SystemColor.inactiveCaption);
      labelContatos.setFont(new Font("Tahoma", Font.PLAIN, 65));

      JLabel labelInformacoes = new JLabel(
            "<html><p><h4 style=\"margin:0\">Centro Universit\u00E1rio Est\u00E1cio do Cear\u00E1</h4><br /><strong>Aluno:</strong> Lucas Holanda Castelo Branco<br /><strong>Professor:</strong> Newton Gomes<br /><strong>Disciplina:</strong> Programa\u00E7\u00E3o Orientada a Objetos</p></html>");
      getContentPane().add(labelInformacoes, "4, 4, left, top");

      JButton botaoFechar = new JButton("Fechar");
      botaoFechar.addActionListener(new SairHandler());
      botaoFechar.setIcon(new ImageIcon(SobreControl.class.getResource("/br/fic/poo/images/mini-exit.png")));
      getContentPane().add(botaoFechar, "4, 6, right, default");

      setVisible(true);
   }

   private class SairHandler implements ActionListener
   {

      @Override
      public void actionPerformed(ActionEvent e)
      {
         dispose();
         instancia = null;
      }
   }

}
